<template>
  <div style="text-align: center">
    <el-form ref="form" :model="form" label-width="120px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="借款人姓名" prop="bn">
            <el-input v-model="form.bn"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证号码" prop="bc">
            <el-input v-model="form.bc"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="抵押人姓名" prop="pn">
            <el-input v-model="form.pn"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证号码" prop="pc">
            <el-input v-model="form.pc"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="抵押物共有人" prop="pa">
            <el-input v-model="form.pa"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证号码" prop="card">
            <el-input v-model="form.card"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="申请金额" prop="money">
            <el-input v-model="form.money"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="24">
          <el-form-item label="房地产地址" prop="add">
            <el-input v-model="form.add"></el-input>
          </el-form-item
          >
        </el-col>
        <el-col :span="24">
          <el-form-item label="产权证号" prop="cnm">
            <el-input v-model="form.cnm"></el-input>
          </el-form-item
          >
        </el-col>
      </el-row>
    </el-form>
    <div>
      <table>
        <tr class="hetongtr">
          <td class="hetongtd">
            <p class="hetongTit">委托合同编码</p>
            <p class="hetongContent">
              {{ this.describeText1
              }}
              <el-input class="hetongInput" v-model="word1"></el-input
              >
              字
              <el-input class="hetongInput" v-model="number1"></el-input>
              号
            </p>
          </td>
        </tr>
        <tr class="hetongtr">
          <td class="hetongtd">
            <p class="hetongTit">反担保抵押合同编码</p>
            <p class="hetongContent">
              {{ this.describeText2
              }}
              <el-input class="hetongInput" v-model="word2"></el-input
              >
              字
              <el-input class="hetongInput" v-model="number2"></el-input>
              号
            </p>
          </td>
        </tr>
        <tr class="hetongtr">
          <td class="hetongtd">
            <p class="hetongTit">反担保合同编码</p>
            <p class="hetongContent">
              {{ this.describeText3
              }}
              <el-input class="hetongInput" v-model="word3"></el-input
              >
              {{ this.describeText4
              }}
              <el-input class="hetongInput" v-model="number3"></el-input>
              号
            </p>
          </td>
        </tr>
      </table>

      <table style="margin-top: 30px">
        <tr class="hetongtr" v-if="isContract != 2">
          <td class="hetongtd">
            <p class="hetongTit">婚姻状况</p>
            <el-radio v-model="form.marriage" label="1">未婚</el-radio>
            <el-radio v-model="form.marriage" label="0">已婚</el-radio>
          </td>
        </tr>
        <tr class="hetongtr" v-if="isContract == 2">
          <td class="hetongtd">
            <p class="hetongTit">婚姻状况</p>
            <el-radio v-model="form.marriage" label="1">未婚</el-radio>
            <el-radio v-model="form.marriage" label="2">已婚</el-radio>
            <el-radio v-model="form.marriage" label="3">已婚单签</el-radio>
            <el-radio v-model="form.marriage" label="4">离异</el-radio>
          </td>
        </tr>
        <!-- <tr class="hetongtr">
          <td class="hetongtd">
            <p class="hetongTit">抵押人与借款人是否为同一人</p>
            <el-radio v-model="form.same" label="1">是</el-radio>
            <el-radio v-model="form.same" label="0">否</el-radio>
          </td>
        </tr>
        <tr class="hetongtr">
          <td class="hetongtd">
            <p class="hetongTit">保证合同</p>
            <el-radio v-model="form.ensure" label="1">需要</el-radio>
            <el-radio v-model="form.ensure" label="0">不需要</el-radio>
          </td>
        </tr> -->
      </table>
    </div>
    <el-button
      type="primary"
      style="width: 150px; margin-top: 30px"
      @click="downloadFun"
    >下载
    </el-button
    >
  </div>
</template>

<script>
import {
  postDownload,
  Lyfcontract,
  Rydcontract,
  guaranteeContractDBAJF,
  downloadGuaranteeContract
} from "../../../src/assets/js/api";

export default {
  name: "Check",
  props: [
    "showForm",
    "isContract",
    "orderData",
    "bdcZ",
    "bdcH",
    "bdcDBZ",
    "bdcDBH",
    "bdcFDBZ",
    "bdcFDBH"
  ],
  // props: {
  //   showForm: {
  //     type: Object,
  //   },
  //   isContract: {
  //     type: Number,
  //   },
  //   orderData: {
  //     type: String,
  //   },
  // },
  data() {
    return {
      form: {
        marriage: "1",
        // same: "0",
        // ensure: "0",
        enm: "",
        pnm: "",
        gnm: "",
        bn: "",
        bc: "",
        add: "",
        pn: "",
        pc: "",
        pa: "",
        pac: "",
        money: "",
        cnm: "",
        card: "",
        orderNum: ""
      },
      word1: "",
      number1: "",
      word2: "",
      number2: "",
      word3: "",
      number3: "",
      describeText1: "",
      describeText2: "",
      describeText3: "",
      describeText4: ""
    };
  },
  created() {
    this.form.bn = this.showForm.basicBorrowerName; // 借款人姓名
    this.form.bc = this.showForm.basicBorrowerCard; // 借款人身份证
    // this.form.add = this.showForm.pledgeHouseAddress; // 房产地址
    if (
      this.showForm.pledgeHouseAddress &&
      this.showForm.pledgeHouseAddressTwo
    ) {
      this.form.add = `${this.showForm.pledgeHouseAddress}、${this.showForm.pledgeHouseAddressTwo}`;
    } else {
      if (this.showForm.pledgeHouseAddress) {
        this.form.add = this.showForm.pledgeHouseAddress;
      } else {
        this.form.add = this.showForm.pledgeHouseAddressTwo;
      }
    } //房产地址!
    this.form.pn = this.showForm.pledgeName; //抵押人姓名
    this.form.pc = this.showForm.pledgeCard; // 抵押人身份证
    this.form.pa = this.showForm.pledgeMateName; //抵押共有人姓名
    this.form.card = this.showForm.pledgeMateCard; // 抵押共有人身份证
    // this.form.cnm = this.showForm.pledgeHouseNumber; // 产权证号!
    if (this.showForm.pledgeHouseNumber && this.showForm.pledgeHouseNumberTwo) {
      this.form.cnm = `${this.showForm.pledgeHouseNumber}、${this.showForm.pledgeHouseNumberTwo}`;
    } else {
      if (this.showForm.pledgeHouseNumber) {
        this.form.cnm = this.showForm.pledgeHouseNumber;
      } else {
        this.form.cnm = this.showForm.pledgeHouseNumberTwo;
      }
    } //房产地址!
    this.form.money = this.showForm.basicLoansMoney; // 申请金额
    // if (this.form.bn == this.form.pn) {
    //   this.form.same = "1";
    // } else {
    //   this.form.same = "0";
    // }
    if (this.isContract == 2) {
      if (this.showForm.basicBorrowerMarriage == "未婚") {
        this.form.marriage = "1";
      }
      if (this.showForm.basicBorrowerMarriage == "已婚") {
        this.form.marriage = "2";
      }
      if (this.showForm.basicBorrowerMarriage == "已婚单签") {
        this.form.marriage = "3";
      }
      if (this.showForm.basicBorrowerMarriage == "离异") {
        this.form.marriage = "4";
      }
    } else {
      if (this.showForm.basicBorrowerMarriage == "已婚") {
        this.form.marriage = "0";
      }
      if (this.showForm.basicBorrowerMarriage == "未婚") {
        this.form.marriage = "1";
      }
    }

    // this.form.money = this.showForm.basicBorrowerMarriage; // 婚姻状况

    if (this.isContract != 2) {
      this.describeText1 = "不动产（新华普惠·重庆银行）";
      this.describeText2 = "不动产担保（新华普惠·重庆银行）";
      this.describeText3 = "不动产（新华普惠·重庆银行）反担保";
    } else if (this.showForm.productType == 25) {
      this.describeText1 = "不动产（新华普惠·大渡口融兴）";
      this.describeText2 = "不动产担保（新华普惠·大渡口融兴）";
      this.describeText3 = "不动产（新华普惠·大渡口融兴）反担保";
    }else if (this.isContract ==2 ) {
      this.describeText1 = "不动产（新华普惠·永川北银）";
      this.describeText2 = "不动产担保（新华普惠·永川北银）";
      this.describeText3 = "不动产（新华普惠·永川北银）反担保";
    }
    this.describeText4 = "字第";
    this.form.orderNum = this.orderData;
    this.word1 = this.bdcZ;
    this.number1 = this.bdcH;

    this.word2 = this.bdcDBZ;
    this.number2 = this.bdcDBH;
    this.word3 = this.bdcFDBZ;
    this.number3 = this.bdcFDBH;
    this.getData();
  },
  methods: {
    getData() {
      if (this.bdcZ !== "undefined") {
        this.word1 = this.bdcZ;
      } else {
        this.word1 = "";
      }
      if (this.bdcH !== "undefined") {
        this.number1 = this.bdcH;
      } else {
        this.number1 = "";
      }
      if (this.bdcDBZ !== "undefined") {
        this.word2 = this.bdcDBZ;
      } else {
        this.word2 = "";
      }
      if (this.bdcDBH !== "undefined") {
        this.number2 = this.bdcDBH;
      } else {
        this.number2 = "";
      }
      if (this.bdcFDBZ !== "undefined") {
        this.word3 = this.bdcFDBZ;
      } else {
        this.word3 = "";
      }
      if (this.bdcFDBH !== "undefined") {
        this.number3 = this.bdcFDBH;
      } else {
        this.number3 = "";
      }
    },
    downloadFun() {
      let that = this;
      that.form.productType=that.showForm.productType;
      // console.log(that)
      if (that.word1 != "" && that.number1 != "") {
        this.form.enm = `${this.describeText1}${that.word1}字${that.number1}号`;
      }
      if (that.word2 != "" && that.number2 != "") {
        this.form.pnm = `${this.describeText2}${that.word2}字${that.number2}号`;
      }
      if (that.word3 != "" && that.number3 != "") {
        this.form.gnm = `${this.describeText3}${that.word3}${that.describeText4}${that.number3}号`;
      }

      this.form.productType=this.showForm.productType;

      downloadGuaranteeContract(this.form).then(res=>{
        window.location.href = res;
      })
      // if (that.word4 != "" && that.number4 != "") {
      //   this.form.cnm = `${this.describeText4}${that.word4}${that.describeText4}${that.number4}号`;
      // }
      // if (this.isContract == 1) {
      //   //乐业保担保合同下载!
      //   postDownload(this.form).then(res => {
      //     // let link = document.createElement("a");
      //     // link.style.display = "none";
      //     // link.href = res;
      //     // link.setAttribute("download", "乐业保合同");
      //     // document.body.appendChild(link);
      //     // link.click();
      //     // document.body.removeChild(link);
      //     window.location.href = res;
      //   });
      // } else if (this.isContract == 2) {
      //   // 融银贷担保合同下载!
      //   Rydcontract(this.form).then(res => {
      //     // console.log(res)
      //     // let link = document.createElement("a");
      //     // link.style.display = "none";
      //     // link.href = res;
      //     // link.setAttribute("download", "融银贷合同");
      //     // document.body.appendChild(link);
      //     // link.click();
      //     // document.body.removeChild(link);
      //     window.location.href = res;
      //   });
      // } else if (this.isContract == 3) {
      //   // 乐业分担保合同下载!
      //   Lyfcontract(this.form).then(res => {
      //     // let link = document.createElement("a");
      //     // link.style.display = "none";
      //     // link.href = res;
      //     // link.setAttribute("download", "乐业分合同");
      //     // document.body.appendChild(link);
      //     // link.click();
      //     // document.body.removeChild(link);
      //     window.location.href = res;
      //   });
      // } else if (this.isContract == 4) {
      //   // 担保安居分保理合同下载!
      //   guaranteeContractDBAJF(this.form).then(res => {
      //     // let link = document.createElement("a");
      //     // link.style.display = "none";
      //     // link.href = res;
      //     // link.setAttribute("download", "乐业分合同");
      //     // document.body.appendChild(link);
      //     // link.click();
      //     // document.body.removeChild(link);
      //     window.location.href = res;
      //   });
      // }
    },
    formResetFields(data) {
      if (data == true) {
        this.form.marriage = "1";
        // this.form.same = "1";
        // this.form.ensure = "1";
        this.form.bn = this.showForm.basicBorrowerName; // 借款人姓名
        this.form.bc = this.showForm.basicBorrowerCard; // 借款人身份证
        this.form.add = this.showForm.pledgeHouseAddress; // 房产地址
        this.form.pn = this.showForm.pledgeName; //抵押人姓名
        this.form.pc = this.showForm.pledgeCard; // 抵押人身份证
        this.form.pa = this.showForm.pledgeMateName; //抵押共有人姓名
        this.form.card = this.showForm.pledgeMateCard; // 抵押共有人身份证
        this.form.cnm = this.showForm.pledgeHouseNumber; // 产权编号
        this.form.money = this.showForm.basicLoansMoney; // 申请金额
        this.form.enm = "";
        this.form.pnm = "";
        this.form.gnm = "";
        // this.form.pn = "";
        // this.form.pc = "";
        // this.form.pa = "";
        // this.form.pac = "";
        // this.form.money = "";
        // this.form.cnm = "";
        this.word1 = "";
        this.number1 = "";
        this.word2 = "";
        this.number2 = "";
        this.word3 = "";
        this.number3 = "";
      }
    }
  }
};
</script>

<style scoped type="less">
.hetongtd {
  width: 650px;
  border: 1px #eeeeee solid;
  height: 40px;
}

.hetongtr {
  width: 100%;
  border: 1px red solid;
}

.hetongInput {
  width: 100px;
  height: 20px !important;
  border: 1px rgba(0, 0, 0, 0) solid;
}

.hetongTit {
  border-right: 1px #eeeeee solid;
  line-height: 40px;
  height: 40px;
  width: 30%;
  float: left;
}

.hetongContent {
  float: left;
  text-align: center;
  width: 65%;
}

.hetongContent ::v-deep.el-input__inner {
  border: 1px rgba(0, 0, 0, 0) solid;
  height: 35px;
}

table {
  width: 100%;
}

.el-radio {
  line-height: 40px;
}
</style>
